import router from "../router";
import $bus from "../utils/bus";

router.beforeEach((to, from) => {
  let touken = sessionStorage.getItem("api-token");
  //判断touken是否是空，如果是空并且跳转的路径不是login，那么就强制性让他跳转到login登录页面
  if (!touken) {
    if (to.path !== "/login") {
      return {
        path: "/login",
      };
    }
  }
});

router.afterEach((to, from) => {
  console.log(to);
  $bus.$emit("breadChange", to.matched);
});
